package interfaces.impl.agents;

import interfaces.AgentInterface;


import interfaces.impl.Agent;

import java.awt.Color;
import java.awt.Graphics;
import java.util.ArrayList;

import constants.*;



import objects.SpetialFeature;
import objects.WorldObject;
import universe.Universe;

public class AgentDrawLife extends Agent implements AgentInterface{

	//i dont know if  i have to search in his list or just give him the reference throw the method
	
	
	public AgentDrawLife(){
		this.id=Constants.AGENT_DRAW_LIFE;
		
	}
	
	@Override
	public void paint(Graphics g, WorldObject object) {
		
		
		SpetialFeature cLife=null;
		SpetialFeature tLife=null;
		
		for(SpetialFeature f : object.getListFeatures()){
			if(f.getId()==Constants.SPETIAL_FEATURE_CURRENT_LIFE){
				cLife=f;
			}
			if(f.getId()==Constants.SPETIAL_FEATURE_LIFE){
				tLife=f;
			}
		}
		
		if(tLife==null || cLife == null){
			return;
		}
		
		int totalLife=(int) tLife.getValue();
		int currentLife=(int) cLife.getValue();	
				
				int greenBar = (int)((currentLife*object.getImageObject().getImageToShow().getWidth())/totalLife);
				
				g.setColor(Color.red);
				g.fillRect((int)object.getImageObject().getPosition().getX(),(int)object.getImageObject().getPosition().getY(), object.getImageObject().getImageToShow().getWidth(), 10);
				
				g.setColor(Color.green);
				g.fillRect((int)object.getImageObject().getPosition().getX(),(int)object.getImageObject().getPosition().getY(), greenBar, 10);
				
				g.setColor(Color.black);
		
		
		
		
	}

	@Override
	public void update(WorldObject object, Universe world, double time) {
		return;
		
	}

	@Override
	public String getName() {
		return "Agente Dibujar Vida";
	}

	@Override
	public void setName(String name) {
		this.name=name;
		
	}

	

	
	

}
